package ru.alt22.visor.php.core.codegen;

public class PHPParameter {
	private String name;
	private String type;
	private String defaultValue;
	
	public PHPParameter(String name, String type, String defaultValue) {
		this.setName(name);
		this.setType(type);
		this.setDefaultValue(defaultValue);
	}
	
	public PHPParameter(String name, String type) {
		this(name, type, null);
	}

	public PHPParameter(String name) {
		this(name, null);
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public String getDefaultValue() {
		return defaultValue;
	}
	
	public String toString() {
		StringBuffer result = new StringBuffer();
		if (type != null && type.length() > 0) {
			result.append(type);
			result.append(" ");
		}
		result.append("$");
		result.append(name);
		if (defaultValue != null && defaultValue.length() > 0) {
			result.append(" = ");
			result.append(defaultValue);
		}
		return result.toString();
	}
	
}
